package com.cqrt.aop;

import com.hustcad.plm.rpm.model.entity.plan.TyppmPlanActive;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Aspect
@Component
@Slf4j
@Transactional
public class PlanAop {

    @Around("execution(* com.hustcad.plm.rpm.service.plan.TyppmPlanService.getPublishContent(..))")
    public Object changePlanSubmitState(ProceedingJoinPoint jp) throws Throwable{
        List<TyppmPlanActive> data = (List<TyppmPlanActive>) jp.proceed();
        data.removeIf(datum -> datum.getOutLineLevel() != null && datum.getOutLineLevel() != 1);
        return data;
    }
}
